package com.Home
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	import com.UI.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	
	public class FrameHomeInvade extends JFrame
	{
		//members define
		private var btn_home_loot:JButton;
		private var btn_home_capture:JButton;
		private var btn_close:JButton;
		public function FrameHomeInvade()
		{
			setResizable(false);
			setBorder(new EmptyBorder());
			
			btn_close = new JButton();
			btn_close.setLocation(new IntPoint(198, 0));
			btn_close.setSize(new IntDimension(27, 27));
			btn_close.setPreferredSize(new IntDimension(27, 27));
			this.getTitleBar().setCloseButton(btn_close);
			this.setClipMasked(false);
			getContentPane().setClipMasked(false);
			getTitleBar().getFrame().setClipMasked(false);
			btn_close.setClipMasked(false);
			getTitleBar().setMinimizeHeight(27);
			
			//component creation
			setSize(new IntDimension(103, 96));
			setPreferredSize(new IntDimension(103, 96));
			var layout0:FlowWrapLayout = new FlowWrapLayout();
			layout0.setPreferWidth(200);
			layout0.setAlignment(AsWingConstants.LEFT);
			layout0.setHgap(25);
			layout0.setVgap(3);
			layout0.setMargin(true);
			getContentPane().setLayout(layout0);
			
			btn_home_loot = new JButton();
			btn_home_loot.setLocation(new IntPoint(23, 0));
			btn_home_loot.setSize(new IntDimension(57, 30));
			btn_home_loot.setPreferredSize(new IntDimension(57, 30));
			btn_home_loot.setText("label");
			
			btn_home_capture = new JButton();
			btn_home_capture.setLocation(new IntPoint(0, 0));
			btn_home_capture.setSize(new IntDimension(57, 30));
			btn_home_capture.setPreferredSize(new IntDimension(57, 30));
			btn_home_capture.setText("label");
			
			//component layoution
			getContentPane().append(btn_home_loot);
			getContentPane().append(btn_home_capture);
			
			var img_char_background:DisplayObject = Client.getUIElement("img_home_invade_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSize(new IntDimension(img_char_background.width, img_char_background.height));
			setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
			btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			btn_home_capture.wrapSimpleButton(Client.getUIElement("btn_home_capture") as SimpleButton);
			btn_home_capture.setText("");
			btn_home_loot.wrapSimpleButton(Client.getUIElement("btn_home_loot") as SimpleButton);
			btn_home_loot.setText("");
			btn_home_loot.addActionListener(onBtnLoot);
			btn_home_capture.addActionListener(onBtnCapture);
		}
		private function onBtnLoot(e:Event):void
		{
			FrameHomeInvade.hide();
			Client.getInstance().sendPacketLogic(1304,[int(Home.homeInfo.m_nCharId),int(FrameHomeInvade._frame.objDest.buildingHomeId),int(0)]);
		}
		private function onBtnCapture(e:Event):void
		{
			FrameHomeInvade.hide();
			Client.getInstance().sendPacketLogic(1304,[int(Home.homeInfo.m_nCharId),int(FrameHomeInvade._frame.objDest.buildingHomeId),int(1)]);
		}
		public var objDest:ObjectHomeBuilding = null;
		public static var _frame:FrameHomeInvade = null;
		public static function show(obj:ObjectHomeBuilding):void
		{
			if(isShowing())
			{
				_frame.hide();
				return;
			}
			if(_frame == null)
			{
				_frame = new FrameHomeInvade();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			_frame.show();
			_frame.objDest = obj;
			_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
			PanelMainHelp.getInstance().bringToTop(_frame);
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
	}
}